import type { MenuProps } from 'antd';
import { slide_router } from '@/router/index'
import {
    DesktopOutlined,
    FileOutlined,
    PieChartOutlined,
    TeamOutlined,
    UserOutlined,
    FolderAddOutlined
} from '@ant-design/icons';

type MenuItem = Required<MenuProps>[`items`][number];

function getItem(
    label: any,
    key?: any | null,
    icon?: React.ReactNode,
    children?: MenuItem[],
    type?: `group`,
): MenuItem {
    return {
        key,
        icon,
        children,
        label,
        type,
    } as MenuItem;
}

const ros1 = slide_router.filter((item: any) => item.path)
const ros2 = ros1[1].children?.filter((v: any) => v.path !== '')
const ros3: any = ros2?.filter((c: any,) => c.children)

const path: string = '/afeng/'

const items: MenuItem[] = [
    getItem(`网站基本配置`, `${path}home`, <PieChartOutlined />),
    getItem(`管理员信息`, `${path}user_control`, <DesktopOutlined />, [
        getItem(`用户列表`, `${path}user_control/userlist`)
    ]),
    getItem(`我的`, `${path}authority_management`, <UserOutlined />, [
        getItem(`添加管路员`, `${path}authority_management/action_list`),
        getItem(`权限列表`, `${path}authority_management/jurisdiction_list`),
        getItem(`修改角色`, `${path}authority_management/update_action`),
    ]),
    // getItem(`新闻管理`, `${path}news_management`, <TeamOutlined />, [
    //     getItem(`新闻列表`, `${path}news_management/news_list`),
    //     getItem(`撰写新闻`, `${path}news_management/write_news`),
    //     getItem(`新闻更新`, `${path}news_management/news_update`),
    //     getItem(`新闻预览`, `${path}news_management/news_prev`),
    //     getItem(`新闻分类`, `${path}news_management/news_classify`),
    //     getItem(`草稿箱`, `${path}news_management/drafts`),
    // ]),
    // getItem(`审核管理`, `${path}auditlist`, <FileOutlined />, [
    //     getItem(`审核新闻`, `${path}auditlist/censor_news`),
    //     getItem(`审核列表`, `${path}auditlist/censor_list`),
    // ]),
    // getItem(`发布管理`, `${path}publish`, <FolderAddOutlined />, [
    //     getItem(`待发布`, `${path}publish/release`),
    //     getItem(`已发布`, `${path}publish/publish`),
    //     getItem(`已下线`, `${path}publish/offline`),
    // ]),
];


const separation = (el:any,i?:any) => {
//   console.log(el);
  [el].map((h:any,i:any) => h)
}

const rightList = ros2?.map((item: any) => {
    separation(item.children)
    return getItem(item.label, path + item.path, item.icon,)
})

// console.log(separation);


const data: MenuItem[] = []


// export default items

export default items